<template>
	<view class="examCard">
		<view class="top">
			<view class="title">
				{{examItem.name}}
			</view>
			<u-tag class="tag" :text="ExamStatusName" :type="statusColor" />
		</view>
		<view class="middle">
			<view v-if="examItem.examTime>0">总分：<text>{{examItem.maxScore}}</text> 分 &emsp;&emsp;
				考试时长：<text>{{examItem.examTime}}</text> 分钟</view>
			<view v-else>总分：<text>{{examItem.maxScore}}</text> 分 &emsp;&emsp;
				考试时长：<text>不限时长</text> </view>
			<view>开始时间：{{examItem.examStartTime}}</view>
			<view>结束时间：{{examItem.examEndTime}}</view>

		</view>
		<view class="bottom">
			<button class="bottomBtn" :ripple="true" @click="checkExam" v-if="examItem.canCheckGrade">
				<u-icon class="bottomIcon" name="checkmark" color="#7f878c" size="32"></u-icon>
				<view class=""> 查看成绩 </view>
			</button>

			<button class="bottomBtn" :ripple="true" @click="enterExam" v-if="examItem.canStartExam">
				<u-icon class="bottomIcon" name="clock" color="#7f878c" size="32"></u-icon>
				<view class=""> 参加考试 </view>
			</button>
<!-- 			<button class="bottomBtn" :ripple="true" @click="enterExam" v-if="showContinueExam">
				<u-icon class="bottomIcon" name="clock" color="#7f878c" size="32"></u-icon>
				<view class=""> 继续考试 </view>
			</button> -->
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			examItem: Object,
		},
		data() {
			return {
				showEnterExam: true,
				showContinueExam: false,
				showCheckGrade: false,
			}
		},
		computed: {
			status() {
				return this.examItem.status
			},
			studentExamStatus() {
				return this.examItem.studentExamStatus
			},
			ExamStatusName: function() {
				switch (this.examItem.status) {
					case 1:
						return "未开始"
						break;
					case 2:
						return "考试中"
						break;
					case 3:
						return "已结束"
						break;
					default:
						return "等待安排"
				}
			},
			statusColor: function() {
				switch (this.examItem.status) {
					case 1:
						return "info"
						break;
					case 2:
						return "success"
						break;
					case 3:
						return "warning"
						break;
					case 4:
						return "success"
						break;
					case 5:
						return "error"
						break;
					default:
						return "info"
				}
			}
		},
		methods: {
			enterExam() {
				// 页面跳转 传递对象 传对象
				// 字符串太长会断，而且需要把参数里面不能通过url传递的字符进行编码，所以用encodeURIComponent
				var examItemObj = encodeURIComponent(JSON.stringify(this.examItem))
				this.$u.route('pages/exam/examPromise', {
					examItemObj: examItemObj
				});
			},
			checkExam() {
				this.$u.route('pages/exam/exam1', {
					examName: this.examItem.name
				});
			}
		},
		filters: {
			contentFilter(item) {
				if (item == null || item.length == 0) {
					return "100"
				}
			}
		},
	}
</script>

<style lang="scss">
	button::after {
		border: none;

	}

	.examCard {
		box-shadow: 0 0 5px 1px rgba($color: #000000, $alpha: 0.1);
		margin: 15rpx;
		border-radius: 15upx;
		padding: 25rpx 25rpx 0 25rpx;
		font-size: $uni-font-size-base;

		.top {
			padding-bottom: 10rpx;
			display: flex;
			justify-content: space-between;
			border-bottom: solid 1px #EEEEEE;

			.title {
				font-size: $uni-font-size-title;
				font-weight: bold;
				color: #0080d1;
			}

			.tag {
				height: 50upx;
			}
		}

		.middle {
			padding: 15upx 0;
			color: $uni-text-color;
			border-bottom: solid 1px #EEEEEE;

			text {
				color: $theme-color;
				font-weight: bold;
			}
		}

		.bottom {
			display: flex;
			color: #7f878c;

			.bottomBtn {
				background-color: #FFFFFF;
				color: #000000;
				display: flex;
				font-size: 30rpx;

				.bottomIcon {
					margin: 0rpx 10rpx;
				}
			}
		}
	}
</style>
